<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>交易所新增</title>
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/global.css" media="all">
    <link rel="stylesheet" href="/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/table.css"/>
    <script type="text/javascript" src="/plugins/layui/layui.js"></script>
    <script type="text/javascript" src="/js/global-config.js"></script>
     <style>
        .layui-form-label {
            width: 10%;
        }
        .layui-input-block {
            margin-left: 13%;
        }
        img {
            width: 200px;
            height: 120px;
        }
        .layui-upload-list {
            margin-left: 13%;
        }
    </style>
</head>
<body>
<div style="margin: 15px;">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>添加交易(<label class="layui-required-tip">标红的为必填项</label>)</legend>
    </fieldset>
    <form class="layui-form" id="layui-form" action="" method="post">
        <div class="layui-form-item" style="display: none;">
            <label class="layui-form-label layui-required-tip">ID：</label>
            <div class="layui-input-block">
                <select  id="id" name="id" class="layui-input" lay-filter="required" style="padding: 0px 20px;"></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-required-tip">交易所名称：</label>
            <div class="layui-input-block">
                <input type="text" id="exchangeName" name="exchangeName" maxlength="100" lay-verify="required" placeholder="请输入交易所名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-required-tip">交易所别名：</label>
            <div class="layui-input-block">
                <input type="text" id="exchangeAliasName" name="exchangeAliasName" lay-verify="required"  maxlength="100" placeholder="请输入交易所别名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">官网地址：</label>
            <div class="layui-input-block">
                <input type="text" maxlength="100" id="officialWebsiteAddres" name="officialWebsiteAddres" lay-verify="required" placeholder="请输入官网地址" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
                <label class="layui-form-label">所在地：</label>
                <div class="layui-input-block" id="countryId">
<!--                    <select  id="province" name="countryId" class="layui-input"  style="padding: 0px 20px;"  lay-search>
                        <option value="">直接选择或搜索选择</option>
                        <#if areaList??>
                            <#list areaList as al>
                                <option value="${al.id}">${al.name!}</option>
                            </#list>
                        </#if>
                    </select>-->
                </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-required-tip">指数：</label>
            <div class="layui-input-block">
                <input type="text" id="index" maxlength="5" name="index" required  lay-verify="required|number" placeholder="请输入指数" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序：</label>
            <div class="layui-input-block">
                <input type="text" id="sort" maxlength="5" name="sort" lay-verify="required|number" placeholder="请输入排序" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态：</label>
            <div class="layui-input-block" id="enableFlag" >
                <input type="radio" name="enableFlag" value="1" title="启用" checked>
                <input type="radio" name="enableFlag" value="0" title="停用">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否前十：</label>
            <div class="layui-input-block" id="rankTenFlag" >
                <input type="radio" name="rankTenFlag" value="1" title="是" >
                <input type="radio" name="rankTenFlag" value="0" title="否" checked>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">交易所K线状态：</label>
            <div class="layui-input-block" id="klineStatus" >
                <input type="radio" name="klineStatus" value="1" title="启用">
                <input type="radio" name="klineStatus" value="0" title="停用" checked>
            </div>
        </div>
       
        
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="save">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary" id="reset" >重置</button>
                <a href="javascript:history.back();" class="layui-btn">返回</a>
            </div>
        </div>
    </form>
</div>
<script>
    layui.config({
        base: '/js/' //假设这是你存放拓展模块的根目录
    }).extend({ //设定模块别名
        selectN: 'selectN' //如果 mymod.js 是在根目录，也可以不用设定别名
    });
    layui.use(['jquery','table','laydate','layer','form','util','selectN'],function(){
        var $=layui.jquery,table=layui.table,laydate = layui.laydate,
            layer = layui.layer,form = layui.form,util=layui.util,selectN=layui.selectN;

        //无限极联动下拉框
        var countryId = selectN({
            elem: '#countryId'
            ,data: "/manage/exchange/selSysArea"
            ,last:true
            ,sync:false
            ,tips: '请选择'
            ,field:{idName:'id',titleName:'name',childName:'children'}
        });

        //监听提交
            form.on('submit(save)', function(data){
             if(countryId.isSelected){
              		data.field.countryName=countryId.lastName;
             }else{
                 layer.msg("请选择所在地",{icon:5, shift: 6 });
                 return false;
             }
          	  $.ajax({
                    type : "POST",
                    url : "/manage/exchange/saveExchange",
                    dataType : "json",
                    data :data.field,
                    success : function(data) {
                  	  layer.alert(data.msg, {
                  		    skin: 'layui-layer-molv' //样式类名  自定义样式
                  		    ,closeBtn: 1    // 是否显示关闭按钮
                  		    ,anim: 1 //动画类型
                  		    ,btn: ['确定'] //按钮
                  		    ,icon: data.code>=0?1:2    // icon
                  		    ,yes:function(index){
                  		    	if (data.code >= 0) {
                  	                  location.href = "/manage/exchange/exchangeInfoList";
                  	              }else{
                  	            	  layer.close(index);
                  	              }
                  		    }});
                    },
                    error : function() {
                        alert("系统异常,请稍后重试");
                    }
                });
              return false;
            });

            //重置下拉框
            $("#reset").on("click",function () {
                countryId.set();
            })
    })
</script>
</body>
</html>